<%= javascript_include_tag 'ufo' %>


<% if edit_media.is_a? Artist 
	@medias = Media.find_all_by_artist_id(edit_media.id).sort_by {|a, b| media_sort_helper a,b }
	else if edit_media.is_a? Artwork
		@medias = Media.find_all_by_artwork_id(edit_media.id).sort_by {|a, b| media_sort_helper a,b }
		else
		@medias = Media.find_all_by_region_id(edit_media.id).sort_by {|a, b| media_sort_helper a,b }
	end
end %>



<% for media in @medias %>
	<tr id="media_<%= media.id %>_a">
  	<td rowspan="2">
    	<% if media.is_a? Picture%>
  			<div class="thumbnail">
  				<%= image_tag url_for_file_column(media, "file", "seventyfive") %>
  			</div>
    		<%= media.file.split('/').last %>
  		<% elsif media.is_a? Audio%>
  		 <%= mp3_player( 
				{ :file => "/audio/file/" + media.file_relative_path(nil) + ".mp3", :displayheight => 0 },
				{ :id => media.id, :width => 300, :height => 40 } ) %>
  	  <% else %>
  		  <%= media_player( 
				{:file => "/video/file/" + media.file_relative_path(subdir = nil)+".flv"},
				{:id => media.id} )%>
  		<% end %>
  	</td>
  </tr>
  
<tr id="media_<%= media.id %>_b"><td>
  Caption:
	<% remote_form_for(:media, media, :url => {:controller => 'admin/medias', :action => "update"}) do |f|%>
	<%= hidden_field_tag :id, media.id.to_s %>
	<%= f.text_area :caption, {:id => 'caption_' + media.id.to_s, :rows => 3, :cols => 30} %>
  <br /><br />
  <%= submit_tag l(:common, 'update') %>    
  <%= link_to_remote 'Delete Media', :html => {:class => "delete"}, :confirm => "Are you sure you wish to permanently delete this image?", :url => {:controller => '/admin/medias', :action => 'destroy', :artwork_id => nil, :artist_id => nil, :id => media.id} %>
	<% end %>
</td></tr>
<% end %>